﻿using Furion.DynamicApiController;
using HOPU.OnlineSchool.Application.Courses.Dtos;
using HOPU.OnlineSchool.Application.Courses.Services;
using HOPU.OnlineSchool.Core;
using Microsoft.AspNetCore.Authorization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HOPU.OnlineSchool.Application.Courses
{
    [AllowAnonymous]
    public class CourseAppService : IDynamicApiController
    {
        /// <summary>
        /// 课程
        /// </summary>
        private readonly ICourseService _courseService;

        public CourseAppService(ICourseService courseService)
        {
            this._courseService = courseService;
        }
        /// <summary>
        /// 课程列表查询
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        [AllowAnonymous]

        public async Task<PagedList<EduCourse>> List(int page, int limit, CouseSearchDto input)
        {
            return await _courseService.GetListSync(page, limit, input);
        }
        [AllowAnonymous]
        public async Task<string> Add(EduCourse model)
        {
            return await _courseService.AddSync(model);
        }
        //获取课程目录的 下拉框数据
        public async Task<List<SelectDto>> GetSubjectSelect(string parentId)
        {
            return await _courseService.GetSubjectSelect(parentId);
        }
        /// <summary>
        /// 获取教师下拉框
        /// </summary>
        /// <returns></returns>
        public async Task<List<SelectDto>> GetTeacherSelect()
        {
            return await _courseService.GetTeacherSelect();
        }
        /// <summary>
        /// 删除课程
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<string> Delete(string id)
        {
            return await _courseService.DeleteSync(id);
        }
        /// <summary>
        /// 根据教师编号获取教师信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<EduCourse> Get(string id)
        {
            return await _courseService.GetCourseAsync(id);
        }
        /// <summary>
        /// 更新教师信息
        /// </summary>
        /// <param name="id"></param>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task Update(string id, EduCourse dto)
        {
            await _courseService.UpdateAsync(id, dto);
        }
    }
}
